package com.letv.app.ljodfh.base;

import com.ruihang.generalibrary.ui.fragment.BaseGeneraFragment;
import com.letv.app.ljodfh.utils.UserManager;

/**
 * Created by liuyu on 2017/8/10.
 */

public class BaseFragment extends BaseGeneraFragment {

    protected boolean isThisShowing;

    protected int userExpiredCode;

    protected static String rebllionUrl;

    protected static String topicUrl;

    private static int rebllionChannelId;
    private static int topicChannelId;

    protected int othersHeight;

    public static void setRebllionUrl(String rebllionUrl) {
        BaseFragment.rebllionUrl = rebllionUrl;
    }

    public static void setTopicUrl(String topicUrl) {
        BaseFragment.topicUrl = topicUrl;
    }

    public static String getRebllionUrl() {
        return rebllionUrl;
    }

    @Override
    public void onResume() {
        super.onResume();
        if (isThisShowing) {
            setThisFragmentShowing();
        }
    }

    @Override
    public void onPause() {
        isThisShowing = false;
        super.onPause();
    }

    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
        isThisShowing = isVisibleToUser;
    }

    @Override
    public void onHiddenChanged(boolean hidden) {
        super.onHiddenChanged(hidden);
        isThisShowing = !hidden;
    }

    protected void setThisFragmentShowing(){
//        JLog.e("ddac  will set Fragment to showing");
        isThisShowing=true;
        UserManager.setActiveFragment(this);
    }

    public boolean isThisShowing() {
        return isThisShowing;
    }

    public void onUserExpired(int code) {
        if (userExpiredCode != code) {
            userExpiredCode = code;
            onUserExpired();
        }
    }

    protected void onUserExpired() {
    }

    public boolean hasShowPlayer(){
        return false;
    }

    public void willDoExit(){}

    public static int getRebllionChannelId() {
        return rebllionChannelId;
    }

    public static void setRebllionChannelId(int rebllionChannelId) {
        BaseFragment.rebllionChannelId = rebllionChannelId;
    }

    public static int getTopicChannelId() {
        return topicChannelId;
    }

    public static void setTopicChannelId(int topicChannelId) {
        BaseFragment.topicChannelId = topicChannelId;
    }

    public int getOthersHeight() {
        return othersHeight;
    }

    public void setOthersHeight(int othersHeight) {
        this.othersHeight = othersHeight;
    }
}
